﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="fsw.Web.Card.List" ValidateRequest="false" %>

<%@ Import Namespace="fsw.Common" %>
<%@ Register Src="~/HeaderJs.ascx" TagPrefix="uc1" TagName="HeaderJs" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="renderer" content="webkit" />
    <title>卡片管理</title>
    <uc1:HeaderJs runat="server" ID="HeaderJs" />
    <script src="/public/admin/js/clipboard.min.js"></script>
    <link href="/public/ckin/css/ckin.min.css" rel="stylesheet" />

</head>
<body>
    <div class="position">当前位置：<a href="List.aspx">卡片管理</a><%=_Nav %></div>
    <div class="border">
        <div class="imagelist2">
            <ul id="list">
                <%foreach (fsw.Model.DirFile m in _List_dirfil)
                  { 
                %>
                <li><a href="List.aspx?url=<%=m.DirFileUrl %>">
                    <div class="preview">
                        <img src="/public/admin/images/default-file.jpg" />
                    </div>
                    <p class="file-title"><%=m.DirFileName %></p>
                </a></li>
                <%}
                  foreach (fsw.Model.Card m in _List_file)
                  {
                      if (Utils.CheckFileMov(m.FileUrl))
                      { 
                %>
                <li>
                    <div class="preview listmov" data-url="<%=m.FileUrl %>" data-title="<%=m.FileName %>">
                        <img src="/public/admin/images/shipin.jpg" title="名称：<%=m.FileName %>&#10时间：<%=m.FileTime %>&#10大小：<%=m.FileSize.ToString() %>K" data-title="<%=m.FileName %>" />
                    </div>
                    <p class="file-title"><%=m.FileName %></p>
                </li>
                <%  
                      }
                      else
                      {                   
                %>
                <li>
                    <div class="preview listfile" data-url="<%=m.FileUrl %>" data-urlto="<%=m.FileClickUrl %>">
                        <img src="<%=m.FileUrl %>" title="名称：<%=m.FileName %>&#10时间：<%=m.FileTime %>&#10大小：<%=m.FileSize.ToString() %>K" data-title="<%=m.FileName %>" />
                    </div>
                    <p class="file-title"><%=m.FileName %></p>
                </li>
                <%
                      }
                  } %>
            </ul>
        </div>
    </div>
    <script>
        $(function () {
            $(".listfile").click(function (i) {
                var _val = $(this).attr("data-id");
                var url = $(this).attr("data-url");
                var urlto = $(this).attr("data-urlto");
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    shadeClose: true,
                    content: ' <img src="' + url + '" style="max-width:360px;" class="fq-copy"><span style="display:none"><img src="Show.aspx?url=' + url + '"></span><div class="layui-content" style="width:0;height:0;overflow:hidden"><img src="' + urlto + '"></div>'
                });
            });
            $('.listmov').on('click', function () {
                var _url = $(this).attr("data-url");
                var _title = $(this).attr("data-title");
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    shadeClose: true,
                    content: '<video poster="/public/admin/images/video.png" src="' + _url + '" data-ckin="default" data-overlay="1" data-title="' + _title + '" width="350px"></video><script src="/public/ckin/js/ckin.min.js"><\/script>'
                });
            })
        })
        var clipboard = new ClipboardJS('.fq-copy', {
            target: function () {
                return document.querySelector('.layui-content');
            }
        });
        clipboard.on('success', function (e) {
            var _src = document.querySelector('.fq-copy').src;
            var _search = window.location.search;
            var Pid = 0;
            var PicPath = "";
            var PicName = "";
            if (_search && _search.split('=').length > 0) {
                PicPath = _search.split('=')[1];
                Pid = PicPath.replace('/', '').split('_')[0];
            }
            if (_src) {
                PicName = _src.split('/')[_src.split('/').length - 1];
            }
            $.ajax({
                type: 'post',
                cache: false,
                dataType: 'json',
                url: 'CardAdd.aspx',
                data: 'Pid=' + Pid + "&PicPath=" + PicPath + "&PicName=" + PicName,
                error: function (e) { alert(e.responseText); },
                success: function (d) {
                    if (d.state == 'success') {
                        toastr.success('复制成功!');
                    }
                    else if (d.state == 'error') {
                        toastr.error(d.msg);
                    }
                }
            })

        });
        clipboard.on('error', function (e) {
            toastr.error('error')
        });
        $(function () {
            $(".listfile").find('img').hover(function () {
                var _this = $(this);
                var _title = _this.attr('title');
                var _data_title = _this.attr('data-title');
                _this.attr('data-id', _title);
                $.ajax({
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    url: 'CardClick.aspx',
                    data: "PicPath=<%=_Url%>&PicName=" + _data_title,
                    error: function (e) { alert(e.responseText); },
                    success: function (d) {
                        _this.attr('title', _title + '\n查看：' + d[0] + '\n复制：' + d[1]);
                    }
                })
            }, function () {
                var _this = $(this);
                var _title = _this.attr('data-id');
                _this.attr('title', _title);
            })
        })
        $(document).on('mousewheel DOMMouseScroll', onMouseScroll);
        function onMouseScroll(e) {
            var o = document.querySelector('.fq-copy');
            if (o != null) {
                var zoom = parseInt(o.style.zoom, 10) || 100;
                zoom += event.wheelDelta / 12;
                if (zoom > 0) o.style.zoom = zoom + '%';
                return false;
            }
        }
    </script>


</body>
</html>
